package exception;

import java.io.FileOutputStream;
import java.io.IOException;

/**
 * JDK7之后java推出了自动关闭特性
 */
public class AutocloseableDemo {
    public static void main(String[] args) {
        try(
                FileOutputStream fos = new FileOutputStream("fos.dat");
        ) {
            fos.write(1);
        } catch (IOException e) {
            System.out.println("出错了");
        }
    }
}
